<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <p ref="wanho">{{ msg }}</p>
        <div ref="welcome">{{ name }}</div>

        <button @click="show">点我</button>
        <hr>


        <p ref="hello">{{ address }}</p>
        <button @click="modify">修改address</button>

    </div>
    
    
    
</body>
</html>
<script>
    var vm = new Vue({
        // el: '#app',
        data: {
            msg: 'hello',
            name: 'tom',
            address: '南京'
        },
        methods: {
            show(){
                // console.log(this)
                // console.log(this.msg)
                // console.log(this.name)

                console.log(this.$refs.wanho) // 获取DOM元素
            },
            modify(){
                this.address = '上海'
                console.log(this.address)

                // 此时DOM还没更新，需要时间来更新页面
                this.$nextTick(function(){
                    // 页面更新完成后，才会执行！！！
                    console.log(this.$refs.hello.innerText)
                })
            }
        }
    }).$mount('#app')

    // console.log(vm.$el)

    // vm.$mount('#app')

    // vm.$destroy()


</script>